<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>等待信号</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.pcntl-sigtimedwait.html">« pcntl_sigtimedwait</a></li>
      <li style="float: right;"><a href="function.pcntl-strerror.html">pcntl_strerror »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.pcntl.html">PCNTL 函数</a></li>
    <li>等待信号</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.pcntl-sigwaitinfo" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pcntl_sigwaitinfo</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pcntl_sigwaitinfo</span> &mdash; <span class="dc-title">等待信号</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.pcntl-sigwaitinfo-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pcntl_sigwaitinfo</strong></span>(<span class="methodparam"><span class="type">array</span> <code class="parameter">$set</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$siginfo</code><span class="initializer"> = ?</span></span>): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>pcntl_sigwaitinfo()</strong></span>函数暂停调用脚本的执行直到接收到<code class="parameter">set</code>
   参数中列出的某个信号。只要其中的一个信号已经在等待状态(比如： 通过
   <span class="function"><a href="function.pcntl-sigprocmask.html" class="function">pcntl_sigprocmask()</a></span>函数阻塞)，
   函数<span class="function"><strong>pcntl_sigwaitinfo()</strong></span>就回立刻返回。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pcntl-sigwaitinfo-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">set</code></dt>

     <dd>

      <p class="para">
       要等待的信号数组。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">siginfo</code></dt>

     <dd>

      <p class="para">
       <code class="parameter">siginfo</code>是一个输出参数，用来返回信号的信息。
      </p>
      <p class="para">
       以下元素会为所有信号设置：
       <ul class="simplelist">
        <li class="member">signo: 信号编号</li>
        <li class="member">errno: 错误编号</li>
        <li class="member">code: 信号代码</li>
       </ul>
      </p>
      <p class="para">
       下面元素可能会为<strong><code>SIGCHLD</code></strong>信号设置:
       <ul class="simplelist">
        <li class="member">status: 退出的值或信号</li>
        <li class="member">utime: 用户消耗的时间</li>
        <li class="member">stime: 系统（内核）消耗的时间</li>
        <li class="member">pid: 发送进程ID</li>
        <li class="member">uid: 发送进程的实际用户ID</li>
       </ul>
      </p>
      <p class="para">
       信号<strong><code>SIGILL</code></strong>,
       <strong><code>SIGFPE</code></strong>, <strong><code>SIGSEGV</code></strong> 和
       <strong><code>SIGBUS</code></strong> 可能会被设置的元素:
       <ul class="simplelist">
        <li class="member">addr: 发生故障的内存位置</li>
       </ul>
      </p>
      <p class="para">
       可能会为<strong><code>SIGPOLL</code></strong>
       信号设置的元素：
       <ul class="simplelist">
        <li class="member">band: Band event</li>
        <li class="member">fd: 文件描述符</li>
       </ul>
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pcntl-sigwaitinfo-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时，函数<span class="function"><strong>pcntl_sigwaitinfo()</strong></span>返回一个信号编号。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.pcntl-sigwaitinfo-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3279">
    <p><strong>示例 #1 <span class="function"><strong>pcntl_sigwaitinfo()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Blocking&nbsp;SIGHUP&nbsp;signal\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">pcntl_sigprocmask</span><span style="color: #007700">(</span><span style="color: #0000BB">SIG_BLOCK</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #0000BB">SIGHUP</span><span style="color: #007700">));<br /><br />echo&nbsp;</span><span style="color: #DD0000">"Sending&nbsp;SIGHUP&nbsp;to&nbsp;self\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">posix_kill</span><span style="color: #007700">(</span><span style="color: #0000BB">posix_getpid</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">SIGHUP</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #DD0000">"Waiting&nbsp;for&nbsp;signals\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$info&nbsp;</span><span style="color: #007700">=&nbsp;array();<br /></span><span style="color: #0000BB">pcntl_sigwaitinfo</span><span style="color: #007700">(array(</span><span style="color: #0000BB">SIGHUP</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pcntl-sigwaitinfo-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.pcntl-sigprocmask.html" class="function" rel="rdfs-seeAlso">pcntl_sigprocmask()</a> - 设置或检索阻塞信号</span></li>
    <li class="member"><span class="function"><a href="function.pcntl-sigtimedwait.html" class="function" rel="rdfs-seeAlso">pcntl_sigtimedwait()</a> - 带超时机制的信号等待</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>